package Library.items;
import java.util.Date;

public class SearchedBook {

	private int book_id;
	private String title;
	private String authorFirstName;
	private String authorLastName;
	private String description = "";
	private int user_id;
	private Date date_taken;
	private Date date_returned;
	
	public SearchedBook() {
	}
	
	public String getTitle() {
		return title;
	}

	public String getAuthorFirstName() {
		return authorFirstName;
	}

	public String getAuthorLastName() {
		return authorLastName;
	}
	
	public SearchedBook(String title, String authorFirstName, String authorLastName) {
		
		if (isValidParam(title)) {
			this.title = title;
		}
		this.authorFirstName=authorFirstName;
		this.authorLastName=authorLastName;
	}

	public SearchedBook(int id, String title, String author, String description,
			int user_id, Date date_t) {
		if (id > 0) {
			book_id = id;
		}
		if (isValidParam(title)) {
			this.title = title;
		}
		
		if (isValidParam(description)) {
			this.description = description;
		}
		if (user_id > 0) {
			this.user_id = user_id;
		}
		this.date_taken = date_t;
	}

	private boolean isValidParam(String title) {
		return title != null && !title.equals("");
	}

	public String getBookStatus() {
		if(user_id==0){
			return "free";
		}else{
			return "reserve";
		}
	}
}
